package StudyCode.summary.zipfile;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.PushbackInputStream;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsePushbackInputStreamToReadBackAndForth {
	public static void main(String[] args) {
		String strExpression = "a = a++ + b;";

		byte bytes[] = strExpression.getBytes();

		ByteArrayInputStream bis = new ByteArrayInputStream(bytes);

		PushbackInputStream pis = new PushbackInputStream(bis);

		int ch;

		try {

			while ((ch = pis.read()) != -1) {
				if (ch == '+') {
					if ((ch = pis.read()) == '+') {
						System.out.print("Plus Plus");
					} else {
						pis.unread(ch);

						System.out.print("+");
					}
				} else {
					System.out.print((char) ch);
				}
			}
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}
}
